
// This file is part of the mstp-lib library, available at http://code.google.com/p/mstp-lib/ 
// Copyright (c) 2011-2014 Adrian Gostin, distributed under the GNU General Public License v3.

#ifndef _802_1Q_2011_PROCEDURES_H
#define _802_1Q_2011_PROCEDURES_H

#include "assert.h"
#include <string.h>

#include "..\base_types.h"

struct BRIDGE;

// 13.27 State machine procedures

bool betterorsameInfo	(BRIDGE*, int givenPort, int givenTree, INFO_IS newInfoIs); // 13.27.a) - 13.27.1
void clearAllRcvdMsgs	(BRIDGE*, int givenPort); // 13.27.b) - 13.27.2
void clearReselectTree	(BRIDGE*, int givenTree); // 13.27.c) - 13.27.3
void disableForwarding	(BRIDGE*, int givenPort, int givenTree);	// 13.27.d) - 13.27.4
void disableLearning	(BRIDGE*, int givenPort, int givenTree);	// 13.27.e) - 13.27.5
void enableForwarding	(BRIDGE*, int givenPort, int givenTree);	// 13.27.f) - 13.27.6
void enableLearning		(BRIDGE*, int givenPort, int givenTree);	// 13.27.g) - 13.27.7
bool fromSameRegion		(BRIDGE*, int givenPort);					// 13.27.h) - 13.27.8
void newTcDetected		(BRIDGE*, int givenPort, int givenTree);	// 13.27.i) - 13.27.9
void newTcWhile			(BRIDGE*, int givenPort, int givenTree);	// 13.27.j) - 13.27.10
void pseudoRcvMsgs		(BRIDGE*, int givenPort);					// 13.27.k) - 13.27.11
RCVD_INFO rcvInfo		(BRIDGE*, int givenPort, int givenTree);	// 13.27.l) - 13.27.12
void rcvMsgs			(BRIDGE*, int givenPort);					// 13.27.m) - 13.27.13
void recordAgreement	(BRIDGE*, int givenPort, int givenTree);	// 13.27.n) - 13.27.14
void recordDispute		(BRIDGE*, int givenPort, int givenTree);	// 13.27.o) - 13.27.15
void recordMastered		(BRIDGE*, int givenPort, int givenTree);	// 13.27.p) - 13.27.16
void recordPriority		(BRIDGE*, int givenPort, int givenTree);	// 13.27.q) - 13.27.17
void recordProposal		(BRIDGE*, int givenPort, int givenTree);	// 13.27.r) - 13.27.18
void recordTimes		(BRIDGE*, int givenPort, int givenTree);	// 13.27.s) - 13.27.19
void setReRootTree		(BRIDGE*, int givenTree);					// 13.27.t) - 13.27.20
void setSelectedTree	(BRIDGE*, int givenTree);					// 13.27.u) - 13.27.21
void setSyncTree		(BRIDGE*, int givenTree);					// 13.27.v) - 13.27.22
void setTcFlags			(BRIDGE*, int givenPort, int givenTree);	// 13.27.w) - 13.27.23
void setTcPropTree		(BRIDGE*, int givenPort, int givenTree);	// 13.27.x) - 13.27.24
void syncMaster			(BRIDGE*);									// 13.27.y) - 13.27.25
void txConfig			(BRIDGE*, int givenPort);					// 13.27.z) - 13.27.26
void txRstp				(BRIDGE*, int givenPort);					// 13.27.aa) - 13.27.27
void txTcn				(BRIDGE*, int givenPort);					// 13.27.ab) - 13.27.28
void updtBPDUVersion	(BRIDGE*, int givenPort);					// 13.27.ac) - 13.27.29
void updtRcvdInfoWhile	(BRIDGE*, int givenPort, int givenTree);	// 13.27.ad) - 13.27.30
void updtRolesTree		(BRIDGE*, int givenTree);					// 13.27.ae) - 13.27.31
void updtRolesDisabledTree (BRIDGE*, int givenTree);				// 13.27.af) - 13.27.32

// 13.26 State machine conditions and parameters
bool allSynced			(BRIDGE*, int givenPort, int givenTree);	// 13.26.a) - 13.26.1
bool allTransmitReady	(BRIDGE*, int givenPort);		// 13.26.b) - 13.26.2
bool cist				(BRIDGE*, int givenTree);		// 13.26.c) - 13.26.3
bool cistRootPort		(BRIDGE*, int givenPort);		// 13.26.d) - 13.26.4
bool cistDesignatedPort	(BRIDGE*, int givenPort);		// 13.26.e) - 13.26.5
unsigned short EdgeDelay(BRIDGE*, int givenPort);		// 13.26.f) - 13.26.6
unsigned short forwardDelay (BRIDGE*, int givenPort);	// 13.26.g) - 13.26.7
unsigned short FwdDelay (BRIDGE*, int givenPort);		// 13.26.h) - 13.26.8
unsigned short HelloTime(BRIDGE*, int givenPort);		// 13.26.i) - 13.26.9
unsigned short MaxAge	(BRIDGE*, int givenPort);		// 13.26.j) - 13.26.11
bool msti				(BRIDGE*, int givenTree);		// 13.26.k) - 13.26.10
bool mstiDesignatedOrTCpropagatingRootPort (BRIDGE*, int givenPort); // 13.26.l) - 13.26.12
bool mstiMasterPort		(BRIDGE*, int givenPort);		// 13.26.m) - 13.26.13
bool rcvdAnyMsg			(BRIDGE*, int givenPort);		// 13.26.o) - 13.26.15
bool rcvdCistMsg		(BRIDGE*, int givenPort);		// 13.26.p) - 13.26.16
bool rcvdMstiMsg		(BRIDGE*, int givenPort, int givenTree);	// 13.26.q) - 13.26.17
bool reRooted			(BRIDGE*, int givenPort, int givenTree);	// 13.26.r) - 13.26.18
bool rstpVersion		(BRIDGE*);						// 13.26.s) - 13.26.19
bool stpVersion			(BRIDGE*);						// 13.26.t) - 13.26.20
bool updtCistInfo		(BRIDGE*, int givenPort);		// 13.26.u) - 13.26.21
bool updtMstiInfo		(BRIDGE*, int givenPort, int givenTree); // 13.26.v) - 13.26.22
bool rcvdXstMsg			(BRIDGE*, int givenPort, int givenTree); // added by us
bool updtXstInfo		(BRIDGE*, int givenPort, int givenTree); // added by us

/*
void setRcvdMsgs		(BRIDGE*, int givenPort); // 13.26.ac - 13.26.12
*/


#endif
